package test.com;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

import org.apache.commons.mail.EmailAttachment;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.leige.utils.email.EmailAddress;
import com.leige.utils.email.EmailSendUtils;

public class MyEmail {
	public static void main(String[] args) throws IOException {
			ApplicationContext ct =  new ClassPathXmlApplicationContext("classpath:conf/spring/message/spring-message-email.xml");
			EmailSendUtils emailUtils= (EmailSendUtils) ct.getBean("MyQQ-EmailUtils");
			
//			emailUtils.sendText("这是测试的主题", "这是测试的消息", new EmailAddress("619137943@qq.com", "我自己的邮箱"), new EmailAddress("974236463@qq.com", "我自己的邮箱")) ;
//			
//			EmailAttachment[] attachments=new EmailAttachment[1];
//			EmailAttachment a = attachments[0]=new EmailAttachment();
//			a.setDescription("文件描述");
//			a.setDisposition("setDisposition");
//			a.setName("123.zip");
//			a.setPath("E:/常用JAR包/quartz-2.2.1-distribution.tar.gz");
//			emailUtils.sendAttachment("这是测试的主题", "这是测试的消息",attachments, new EmailAddress("619137943@qq.com", "我自己的邮箱"));
			URL url=new URL("http://mp.weixin.qq.com/wiki/0/2ad4b6bfd29f30f71d39616c2a0fcedc.html");
			BufferedReader s = new BufferedReader(new InputStreamReader(url.openConnection().getInputStream(),"utf-8"));
			String str=null;
			String sss="";
			while ((str=s.readLine())!=null) {
				sss+=str;
			}
			sss=new String(sss.getBytes(), "utf-8");
			System.out.println(sss);
			emailUtils.sendImageHtml("这是测试的主题", sss, "这是测试的消息", "http://mp.weixin.qq.com/wiki/0/",new EmailAddress("619137943@qq.com", "我自己的邮箱"));
	}
}
